package com.h3c.nem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.h3c.nem.entity.TbOfferPatent;
import org.apache.ibatis.annotations.Insert;

/**
 * 专利信息数据库访问层
 *
 * @author chenyifan
 * @since 2022-06-06 16:34:44
 */
public interface TbOfferPatentMapper extends BaseMapper<TbOfferPatent> {

    @Insert("INSERT INTO tb_offer_patent \n" +
            "(patent_id, worker_id, offer_id, patent_name, apply_date, \n" +
            "apply_no, auth_date, patent_type, update_time) \n" +
            "SELECT \n" +
            "nextval('hrssseq'), a.HC_NO, b.OfferID, b.FName, \n" +
            "CASE WHEN b.FApplyDate = '' THEN NULL WHEN length(b.FApplyDate) != 10 THEN NULL ELSE STR_TO_DATE(b.FApplyDate,'%Y-%m-%d') END, \n" +
            "b.FApplyNO, \n" +
            "CASE WHEN b.FAuthorizationDate = '' THEN NULL WHEN length(b.FAuthorizationDate) != 10 THEN NULL ELSE STR_TO_DATE(b.FAuthorizationDate,'%Y-%m-%d') END, \n" +
            "b.FType, NOW() \n" +
            "FROM Offer_Send_Detail a, Offer_Patents b \n" +
            "WHERE a.id= b.OfferID")
    void initPatentRecordFromHrss();
}

